package com.vote.util;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
 * 常量类
 *
 * 
 */
public class VoteConstants extends Properties {
	
	private static final long serialVersionUID = 6715302331875134045L;
	public static VoteConstants P = null;
	
	/**
	 * 载入所有配置文件
	 */
	public static void initProperties() {
		try {
			P = new VoteConstants();
			String[] arrProFiles = { "vote.properties"};			
			for (String proFile : arrProFiles) {
				System.out.println("load properties file:" + proFile);
				P.load(VoteConstants.class.getResourceAsStream("/" + proFile));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 读取配置文件中内容
	 * 
	 * @param key
	 * @return
	 */
	public static String get(String key){
		String value = "";
		try {
			if (key == null) {
				return "";
			}
			if (P.containsKey(key))
				value = new String(P.getProperty(key).getBytes("UTF-8"), "UTF-8");
			else
				value = "";
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return value;
	}
	
	/*
	 * 通用
	 */
	public static final Long COMMON_STATUS_ENABLE = 1L; // 有效
	public static final Long COMMON_STATUS_INVALID = 0L; // 无效
	
	public static final String COOKIE_USER_KEY="USER_COOKIE_KEY";//用户cookie key
		
	public static final Long PRIZE_STATUS_NOT_REDEEM=1l;	//待领取 
	public static final Long PRIZE_STATUS_USED=2l;	//已领取
	
	public static final Long PRIZE_SETTING_ISPRIZE_FALSE=0l;//非奖品
	public static final Long PRIZE_SETTING_ISPRIZE_TRUE=1l;//奖品
	
	public static final Long PRIZE_SETTING_TYPE_REAL=1l;//实物
	public static final Long PRIZE_SETTING_TYPE_VIRTUAL=2l;//虚拟
	
	public static final String QUESTION_PART_A="A";//A套题	
	public static final String QUESTION_PART_B="B";//B套题	
}

